<!--header-->
<link rel="stylesheet" href="/ceca_two/css/costShareOne.css" />
<link rel="stylesheet" href="/ceca_two/css/costShareTwo.css" />
<!--# include virtual="/ceca_two/common/html/header.html"-->
<!--# include virtual="/ceca_two/modules/costnorm/base/costShare.html"-->
		<h1 class="shareName">工程特征</h1>
		<div class="explain">填写说明：以下内容均为必填项，若本项目无此项内容请填写“无”。</div>
		<ul class="projectList" id="secondList"></ul>
		<div class="AllshareTable">
			<dl class="basementless">
				<dt class="basementlessName">
					<span>建筑部位</span>
					<span>分部分项</span>
					<span>技术参数</span>
					<span>工程量</span>
					<span>综合合价（万元）</span>
					<span>操作</span>
				</dt>
			</dl>
		</div>
		<div class="shareCostBtn">
			<div class="saveBtn">
				<a href="">保存</a>
			</div>
			<div class="nextBtn">
				<a href="/ceca_two/modules/costnorm/costShareOne.html">上一步</a>
			</div>
			<div class="nextBtn">
				<a href="/ceca_two/modules/costnorm/costShareThree.html">下一步</a>
			</div>
		</div>
	</div>
</div>
<!--底部-->
<!--# include virtual="/ceca_two/common/html/footer.html"-->

<!--
<script>

var templete=new Array();
$(function(){
	if(localStorage.getItem("templete") == 'null'|| localStorage.getItem("templete") == null){
		$.get("/ceca_two/router/templete.json",function(rest){
			templete = rest;
			localStorage.setItem("templete",JSON.stringify(templete));
			initTemplete(templete);
		});
	}else{
		templete  =  jQuery.parseJSON(localStorage.getItem("templete")); 
		initTemplete(templete);
	}
	
});

function  initTemplete(templete){
	$.each(templete, function(index,data) {
		if(index){
			$("#secondList").append("<li data-code="+data.code+">"+data.name+"</li>")
		}else{
			$("#secondList").append("<li class=\"projectListOne\" data-code="+data.code+">"+data.name+"</li>")
		}
		$.each(data.children || new Array(), function(index2,data2) {
			var html = "<dd class=\"basementlessText\"><div class=\"AllName\"><h1 data-code="+data2.code+">"+data2.name+"</h1></div>";
			html+="<div class=\"AllContent\"><div class=\"BQItem\">";
			html+=data2select(data2.children);
			html+="</div>";
			//html+=data2technology(data2); 
			html+=data2nunber(data2); 
			html+=data2synthesize(data2);
			html+=data2remark(data2); 
			html+="</div>"
			html+="<div class=\"combined\"><span>部位合价（万元）</span><span>15646</span></div></dd>";
			$(".basementless").append(html);
		});
	});
}

function data2select(opt){
	var selectMap = {};
	var html="<div class=\"selList\"><span onclick=\"selList(this)\" data-code=\"0\">不包含</span>";
	html+="<ul class=\"selList\"><li onclick=\"data2selectchildren(this)\" data-code=\"0\">不包含</li>";
	$.each(opt, function(index,data) {
		html +="<li onclick=\"data2selectchildren(this)\" data-code="+data.code+">"+data.name+"</li>";
		if(data.children){
			selectMap[data.code] = data.children;
		}else{
			//selectMap[data.code] = data;
		}
	});
	html+="<li onclick=\"data2selectchildren(this)\">其他<input type=\"text\" /></li></ul></div>"; 
	return html;
}//分部分项

var selectchildren = {}
function data2selectchildren(opt){
	if( Object.prototype.toString.call(selectMap) === '[object Array]' ){
		selectMap = $.map(selectMap, function(d,i) {
			return  d.code==$(opt).data("code")?d:null;
		});
	}else{
		selectMap = selectMap[$(opt).data("code")];
	}
	if(selectMap){
	   var html = data2select(selectMap);
	   $(opt).parents(".BQItem").append(html);
	   $(opt).parents(".BQItem").find(".selList").css("width","50%");
	}
	$(opt).parent("ul").siblings("span").html($(opt).html());
    $(opt).parent("ul").hide();
    var html = data2select(selectMap);
    if(selectMap.para)data2technology(opt,data.para);
}

var technologyMap = {};
function data2technology(opt,data){
	var html ="<div class=\"technology\">";
	$.each(opt, function(index,data) {
		console.dir(data['input'].length);
		html+="<div><i>"+data.name+"</i>";
		if(data['input'].length >1){
			html+="<span class=\"sel\">地下连续墙</span><ul class=\"selList\">";
			$.each(data['input'], function(i,d) {
				html+="<li>"+d+"</li>";
			});
			html+="<li>其他<input type=\"text\" /></li></ul>";			  
		}else{
			html+="<input type=\"text\" name=\"\" id=\"\" value=\"\" />";
		}
		html+="<i>"+data.unit+"</i></div>";
	});
	//如果技术参数有二级的话，在此写；
	html+="</div>";
	console.dir($(opt));
	$(opt).parents(".BQItem").after(html);
	//return html;
}//技术参数

function data2technologychildren(opt){
	
}

function data2nunber(data){
	var html="<div><div class=\"quantities\"><span class=\"area\"></span></div>";
		html+="<div class=\"quantitiesInp\"><input type=\"text\" /></div>";
		html+="<div class=\"unit\">";
		html+="<span class=\"sel\">㎡</span>";
		html+="<ul class=\"selList\">";
		html+="<li>m</li><li>m³</li><li>个</li><li>台</li><li>顶</li><li>樘</li><li>t</li>";
	    html+="</ul></div></div>";
	return html;
}//工程量

function data2synthesize(data){
	var html="<div class=\"synthesize\"><input type=\"text\" name=\"\" id=\"\" value=\"\" /></div>";
    return html;
}//综合合价

function data2remark(data){
	var html="<div class=\"remark\"><i class=\"add\" title=\"添加更多\"></i></div>";
    return html;
}//操作

function selList($this){
	if($($this).siblings("ul").css("display")=="none"){
		$($this).siblings("ul").show();
	}else{
		$($this).siblings().hide();
	}
}//select 点击事件
//function Li($this){
//	$($this).parent("ul").siblings("span").html($($this).html());
//  $($this).parent("ul").hide();
//  console.dir(data.para);
//  if(data.para)data2technology(opt,data.para);
//}

layui.use(['costshareTwo','costshare','civiltwo'], function(){});

</script>
-->
</body>
</html>                              
<script type="text/javascript">
	$.ajax({
		type:"post",
		url:"/guidance_service/front/costIndex/template/get.do",
		data:{
			templateId:1502767515419000
		},success:function (data){

			
			var data = JSON.parse(data.data.templateContent);


			$("#secondList").append("<li class='projectListOne'>建筑装饰工程（无地下室</li>");

			for (i = 0 ; i < data.length ; i++) {
				if (data[i].pId == 0) {
					$(".basementless").append("<dd class='basementlessText'><div class='AllName'><h1>"+
					data[i].name+"</h1></div><div class='AllContent'><div class='BQItem'  data-id='"+
					data[i].id+"'><div class='selList'><span onclick='selList(this)'>不包含</span><ul class='selList xialai'></ul></div></div><div><div class='quantities'><span class='area'></span></div><div class='quantitiesInp'><input type='text'/></div><div class='unit'><span class='sel'>㎡</span><ul class='selList' style='display: none;'></ul></div></div><div class='synthesize'><input type='text'/></div><div class='remark'><i class='add' title='添加更多'></i></div></div></dd>")
				}
			}
			
			for (j = 0 ; j < $(".BQItem").length ; j++) {
				for (i = 0 ; i < data.length ; i++) {
					
					if ($(".BQItem").eq(j).attr("data-id") == data[i].pId) {
						$(".BQItem").eq(j).find(".selList").find(".xialai").append("<li onclick='data2selectchildren(this)' data-id='"+
						data[i].id+"'>"+data[i].name+"</li>")
					}
					
				}
			}
		/*
			$(".basementless").append("<dd class='basementlessText'><div class='AllName'><h1>"+
			name+"</h1></div><div class='AllContent'><div class='BQItem'><div class='selList'><span onclick='selList(this)'>"+
			listname+"</span><ul class='selList'><li onclick='data2selectchildren(this)'>"+
			listname+"</li></ul></div></div></div></dd>")
			*/
		},error:function (){
			alert(2)
		}
	});
	
function data2selectchildren(opt){
	$(opt).parent().prev().html(opt.innerHTML);
	$(opt).parent().hide();
//	console.log(typeof opt.dataset.id)
	
	$.ajax({
		type:"post",
		url:"/guidance_service/front/costIndex/template/get.do",
		data:{
			templateId:1502767515419000
		},success:function (data){
			var data = JSON.parse(data.data.templateContent);
			console.log(data)
		
			
		},error:function (){
			alert(2)
		}
	});
	
	
}	
	
function selList($this){
	if($($this).siblings("ul").css("display")=="none"){
		$($this).siblings("ul").show();
	}else{
		$($this).siblings().hide();
	}
}

</script>